library(ggoncoplot)
library(dplyr, warn.conflicts = FALSE)Input Data
The input for ggoncoplot is a data.frame with 1 row per
mutation. data.frame must contain columns describing the
following:
Gene Symbol
Sample Identifier
(optional) mutation type
(optional) tooltip (character string: what we show on mouse hover over a particular mutation)
These columns can be in any order, and named anything. You define the mapping of your input dataset columns to the required features in the call to ggoncoplot
Minimal Example
# TCGA GBM dataset from TCGAmuations package
gbm_csv <- system.file(package='ggoncoplot', "testdata/GBM_tcgamutations_mc3_maf.csv.gz")
gbm_df <- read.csv(file = gbm_csv, header=TRUE)
gbm_df |>
ggoncoplot(
col_genes = 'Hugo_Symbol',
col_samples = 'Tumor_Sample_Barcode'
)Colour by mutation type
Colour by mutation by specifying col_mutation_type
# TCGA GBM dataset from TCGAmuations package
gbm_csv <- system.file(package='ggoncoplot', "testdata/GBM_tcgamutations_mc3_maf.csv.gz")
gbm_df <- read.csv(file = gbm_csv, header=TRUE)
gbm_df |>
ggoncoplot(
col_genes = 'Hugo_Symbol',
col_samples = 'Tumor_Sample_Barcode',
col_mutation_type = 'Variant_Classification'
)
#>
#> ── Identify Class ──────────────────────────────────────────────────────────────
#> ℹ Found 7 unique mutation types in input set
#> ℹ 0/7 mutation types were valid SO terms
#> ℹ 7/7 mutation types were valid MAF terms
#> ✔ Mutation Types are described using valid MAF terms ... using MAF paleteControl which genes are shown
Show top [n] Genes
Show the 4 most frequently mutated genes using topn
argument
gbm_df |>
ggoncoplot(
col_genes = 'Hugo_Symbol',
col_samples = 'Tumor_Sample_Barcode',
col_mutation_type = 'Variant_Classification',
topn = 4
)
#>
#> ── Identify Class ──────────────────────────────────────────────────────────────
#> ℹ Found 7 unique mutation types in input set
#> ℹ 0/7 mutation types were valid SO terms
#> ℹ 7/7 mutation types were valid MAF terms
#> ✔ Mutation Types are described using valid MAF terms ... using MAF paleteExclude Specific Genes
Lets filter out specific genes, such as TTN and MUC16.
gbm_df |>
ggoncoplot(
col_genes = 'Hugo_Symbol',
col_samples = 'Tumor_Sample_Barcode',
col_mutation_type = 'Variant_Classification',
topn = 10,
genes_to_ignore = c("TTN", "MUC16")
)
#>
#> ── Identify Class ──────────────────────────────────────────────────────────────
#> ℹ Found 9 unique mutation types in input set
#> ℹ 0/9 mutation types were valid SO terms
#> ℹ 9/9 mutation types were valid MAF terms
#> ✔ Mutation Types are described using valid MAF terms ... using MAF paleteGene Subset
lets only show TP53 and TERT
gbm_df |>
ggoncoplot(
col_genes = 'Hugo_Symbol',
col_samples = 'Tumor_Sample_Barcode',
col_mutation_type = 'Variant_Classification',
genes_to_include = c('TP53', 'TERT'),
)
#>
#> ── Identify Class ──────────────────────────────────────────────────────────────
#> ℹ Found 6 unique mutation types in input set
#> ℹ 0/6 mutation types were valid SO terms
#> ℹ 6/6 mutation types were valid MAF terms
#> ✔ Mutation Types are described using valid MAF terms ... using MAF paleteCustom Tooltip
Lets add a custom tooltip that describes the specific mutation
gbm_df |>
mutate(tooltip = paste0(Reference_Allele, ">", Tumor_Seq_Allele2)) |>
ggoncoplot(
col_genes = 'Hugo_Symbol',
col_samples = 'Tumor_Sample_Barcode',
col_mutation_type = 'Variant_Classification',
col_tooltip = 'tooltip' # We'll specify a custom tooltip based on our new 'tooltip' column
)
#>
#> ── Identify Class ──────────────────────────────────────────────────────────────
#> ℹ Found 7 unique mutation types in input set
#> ℹ 0/7 mutation types were valid SO terms
#> ℹ 7/7 mutation types were valid MAF terms
#> ✔ Mutation Types are described using valid MAF terms ... using MAF paleteNote tooltips are html, so if you want to insert a break, just paste
in <br>.
Similarly, if you want to make text in the tooltip bold, try
"<b>text_to_bold<\b>"
Add margin plots
Gene Barplot
How many samples have mutations in each Gene (optionally coloured by mutation type)
gbm_df |>
ggoncoplot(
col_genes = 'Hugo_Symbol',
col_samples = 'Tumor_Sample_Barcode',
col_mutation_type = 'Variant_Classification',
draw_gene_barplot = TRUE
)
#>
#> ── Identify Class ──────────────────────────────────────────────────────────────
#> ℹ Found 7 unique mutation types in input set
#> ℹ 0/7 mutation types were valid SO terms
#> ℹ 7/7 mutation types were valid MAF terms
#> ✔ Mutation Types are described using valid MAF terms ... using MAF paleteTumour Mutation Burden
How many mutations (total) are in each sample
Not implemented yet: coming soon (https://github.com/selkamand/ggoncoplot/issues/30)
Static Plots
gbm_df |>
ggoncoplot(
col_genes = 'Hugo_Symbol',
col_samples = 'Tumor_Sample_Barcode',
col_mutation_type = 'Variant_Classification',
interactive = FALSE
)
#>
#> ── Identify Class ──────────────────────────────────────────────────────────────
#> ℹ Found 7 unique mutation types in input set
#> ℹ 0/7 mutation types were valid SO terms
#> ℹ 7/7 mutation types were valid MAF terms
#> ✔ Mutation Types are described using valid MAF terms ... using MAF palete
